
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2024/12/17
  Time: 10:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">




    <title>数据 - AdminLTE2定制版</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">

    <style>
        .table {
            margin-right: 20px;
        }


    </style>


    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">

    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/iCheck/square/blue.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/morris/morris.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}plugins/datepicker/datepicker3.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.theme.default.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/select2/select2.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.skinNice.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap-slider/slider.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.css">
</head>

<body class="hold-transition skin-purple sidebar-mini">

<div class="wrapper">
    <div class="">



        <!-- 内容头部 -->
        <section class="content-header">
            <h1>
                数据管理
                <small>数据列表</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li><a href="#">数据管理</a></li>
                <li class="active">数据列表</li>
            </ol>
        </section>
        <!-- 内容头部 /-->

        <!-- 正文区域 -->
        <section class="content">

            <!-- .box-body -->
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">用户列表</h3>
                </div>

                <div class="box-body">

                    <!-- 数据表格 -->
                    <div class="table-box">

                        <!--工具栏-->
                        <div class="pull-left">
                            <div class="form-group form-inline">
                                <div class="btn-group ">
                                    <!-- Button trigger modal -->
                                    <button type="submit" class="btn btn-default btn-success" title="新建" data-toggle="modal" data-target="#myModal">
                                        <i class="fa fa-file-o"></i> 新增
                                    </button>

                                    <button type="submit" class="btn btn-default btn-danger" onclick="delAll()" title="删除"><i class="fa fa-trash-o"></i> 批量删除</button>

                                    <a href="${pageContext.request.contextPath}/user/user_list">
                                    <button type="button" class="btn btn-default btn-info" title="刷新"><i class="fa fa-refresh"></i> 刷新</button>
                                    </a>

                                </div>
                            </div>
                        </div>
                        <div class="box-tools pull-right">
                            <form action="${pageContext.request.contextPath}/user/user_list" method="post">
                            <div class="has-feedback form-inline">
                                <input type="text" class="form-control input-sm" name="username" value="${username}" placeholder="用户名"/>
    <%--                            <span class="glyphicon glyphicon-search form-control-feedback" ></span>--%>
                                <input type="submit" name="search" class="btn btn-default" title="搜索" value="搜索"/>
                            </div>
                            </form>
                        </div>
                        <!--工具栏/-->

                        <!--数据列表-->
                        <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                            <thead>
                            <tr>
                                <th class="" style="padding-right:0px;">
                                    <input id="selall" type="checkbox" class="icheckbox_square-blue">
                                </th>
                                <th class="sorting_asc">ID</th>
                                <th class="sorting_desc">用户名</th>
                                <th class="sorting_asc sorting_asc_disabled">邮箱</th>
                                <th class="sorting_desc sorting_desc_disabled">联系方式</th>
                                <th class="sorting">备注</th>
                                <th class="text-center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${userList}" var="item">
                            <tr>
                                <td><input name="ids" type="checkbox" value="${item.id}"></td>
                                <td>${item.id}</td>
                                <td>${item.username}</td>
                                <td>${item.email}</td>
                                <td>${item.tel}</td>
                                <td>${item.remark}</td>
                                <td class="text-center">
                                    <button type="button" onclick="getUserById(${item.id})" class="btn bg-olive btn-xs" data-toggle="modal" data-target="#myModal2">详情</button>
                                    <button type="button" onclick="getUserById(${item.id})"  data-toggle="modal" data-target="#myModal1" class="btn bg-olive btn-xs">编辑</button>
                                    <button type="button" onclick="del(${item.id})" class="btn btn-danger btn-xs">删除</button>
                                </td>
                            </tr>

                            </c:forEach>
                        </table>
                        <!--数据列表/-->
                    </div>
                    <!-- 数据表格 /-->
                </div>
                <!-- /.box-body -->

                <!-- .box-footer-->
                <div class="box-footer">
                    <div class="pull-left">
                        <div class="form-group form-inline">
                            总共${pageInfo.pages} 页，共${pageInfo.total} 条数据。 每页
                            <select class="form-control" id="selectPage" onchange="selectPages()" >
                                <option >1</option>
                                <option >3</option>
                                <option >5</option>
                                <option >10</option>
                                <option >15</option>
                            </select> 条
                        </div>
                    </div>

                    <div class="box-tools pull-right">
                        <ul class="pagination">
                            <li>
                                <a href="${pageContext.request.contextPath}/user/user_list?pageMum=1&pageSize=${pageInfo.pageSize}&username=${username}" aria-label="Previous">首页</a>
                            </li>
                            <li><a href="${pageContext.request.contextPath}/user/user_list?pageMum=${pageInfo.prePage==0?1:pageInfo.prePage}&pageSize=${pageInfo.pageSize}&username=${username}">上一页</a></li>
<%--                            <li><a href="${pageContext.request.contextPath}/user/user_list?pageMum=1&pageSize=${pageInfo.pageSize}&username=${username}">1</a></li>
                            <li><a href="${pageContext.request.contextPath}/user/user_list?pageMum=2&pageSize=${pageInfo.pageSize}&username=${username}">2</a></li>
                            <li><a href="${pageContext.request.contextPath}/user/user_list?pageMum=3&pageSize=${pageInfo.pageSize}&username=${username}">3</a></li>
                            <li><a href="${pageContext.request.contextPath}/user/user_list?pageMum=3&pageSize=${pageInfo.pageSize}&username=${username}">4</a></li>
                            <li><a href="${pageContext.request.contextPath}/user/user_list?pageMum=3&pageSize=${pageInfo.pageSize}&username=${username}">5</a></li>--%>
                            <c:forEach begin="1" end="${pageInfo.pages}" var="i">
                                <li><a href="${pageContext.request.contextPath}/user/user_list?pageMum=${i}&pageSize=${pageInfo.pageSize}&username=${username}">${i}</a></li>
                            </c:forEach>
                            <li><a href="${pageContext.request.contextPath}/user/user_list?pageMum=${pageInfo.nextPage==0?pageInfo.pages:pageInfo.nextPage}&pageSize=${pageInfo.pageSize}&username=${username}">下一页</a></li>
                            <li>
                                <a href="${pageContext.request.contextPath}/user/user_list?pageMum=${pageInfo.pages}&pageSize=${pageInfo.pageSize}&username=${username}" aria-label="Next">尾页</a>
                            </li>
                        </ul>
                    </div>

                </div>
                <!-- /.box-footer-->



            </div>

        </section>
        <!-- 正文区域 /-->
        <%--新增窗口--%>
        <!-- Modal -->
        <!-- /.modal -->
        <%--添加模态框--%>
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <form id="add-form" ><%--action="${pageContext.request.contextPath}/user/add_user"--%>
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">添加用户</h4>
                    </div>
                    <div class="modal-body form-inline">
                    <%--    <div class="form-inline"></div>--%>
                        <table  class="table">
                            <tr>
                                <td  align="right">
                                    <div class="form-group " >
                                        <label for="username">用户名</label>
                                        <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名">
                                    </div>
                                </td>
                                <td >
                                    <div class="form-group">
                                        <label for="password">密码</label>
                                        <input type="text" class="form-control" id="password" name="password" placeholder="请输入密码">
                                    </div>
                                </td>
                            </tr>

                       <tr>
                           <td align="right">
                               <div class="form-group">
                                   <label for="name" >名称</label>
                                   <input type="text" class="form-control" id="name" name="name" placeholder="请输入名称">
                               </div>
                           </td>
                           <td>
                               <div class="form-group">
                                   <label for="email">邮箱</label>
                                   <input type="text" class="form-control" id="email" name="email" placeholder="请输入邮箱">
                               </div>
                           </td>
                       </tr>

                       <tr>
                           <td align="right">
                               <div class="form-group">
                                   <label for="tel">联系方式</label>
                                   <input type="text" class="form-control" id="tel" name="tel" placeholder="请输入联系方式">
                               </div>
                           </td>
                           <td>
                               <div class="form-group">
                                   <label for="remark">备注</label>
                                   <input type="text" class="form-control" id="remark" name="remark" placeholder="请输入备注">
                               </div>
                           </td>
                       </tr>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" onclick="save()" class="btn btn-primary">保存</button>
                    </div>
                    </form>
                </div>
            </div>
        </div>
        <%--修改模态框--%>
        <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <form id="add-form1" ><%--action="${pageContext.request.contextPath}/user/add_user"--%>
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel1">修改用户</h4>
                        </div>
                        <div class="modal-body form-inline">
                            <%--    <div class="form-inline"></div>--%>
                            <table  class="table">
                                <tr align="right">
                                    <td  >
                                        <div class="form-group " >
                                            <label for="username">用户名</label>
                                            <input type="text" class="form-control" id="username1" name="username" placeholder="请输入用户名">
                                        </div>
                                    </td>
                                    <td >
                                        <div class="form-group">
                                            <label for="name" >名称</label>
                                            <input type="text" class="form-control" id="name1" name="name" placeholder="请输入名称">
                                        </div>
                                    </td>
                                </tr>
                                <tr align="right">
                                    <td >
                                        <div class="form-group">
                                            <label for="tel">联系方式</label>
                                            <input type="text" class="form-control" id="tel1" name="tel" placeholder="请输入联系方式">
                                        </div>
                                    </td>
                                    <td>
                                        <div class="form-group">
                                            <label for="email">邮箱</label>
                                            <input type="text" class="form-control" id="email1" name="email" placeholder="请输入邮箱">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right">
                                        <div class="form-group">
                                            <label for="remark">备注</label>
                                            <input type="text" class="form-control" id="remark1" name="remark" placeholder="请输入备注">
                                        </div>
                                        <input type="hidden" id="id1" name="id" >
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" onclick="update()" class="btn btn-primary">修改</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <%--查看模态框--%>
        <%--<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                  &lt;%&ndash;action="${pageContext.request.contextPath}/user/add_user"&ndash;%&gt;
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel2">查看用户</h4>
                        </div>
                        <div class="modal-body form-inline">
                            &lt;%&ndash;    <div class="form-inline"></div>&ndash;%&gt;
                            <table  class="table">
                                <tr align="right">
                                    <td  >
                                        <div class="form-group col-xs-6" >
                                            <label for="username">用户名</label>
                                            <input type="text" class="form-control" id="username2" name="username" disabled="disabled" placeholder="请输入用户名">
                                        </div>
                                    </td>
                                    <td >
                                        <div class="form-group">
                                            <label for="name" >名称</label>
                                            <input type="text" class="form-control" id="name2" name="name"disabled="disabled" placeholder="请输入名称">
                                        </div>
                                    </td>
                                </tr>
                                <tr align="right">
                                    <td >
                                        <div class="form-group">
                                            <label for="tel">联系方式</label>
                                            <input type="text" class="form-control" id="tel2" name="tel" disabled="disabled" placeholder="请输入联系方式">
                                        </div>
                                    </td>
                                    <td>
                                        <div class="form-group">
                                            <label for="email">邮箱</label>

                                            <input type="text" class="form-control" id="email2" name="email" disabled="disabled" placeholder="请输入邮箱">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2"  align="center">
&lt;%&ndash;                                        <div class="form-group">
                                            <label for="remark">备注</label>
                                            <input type="text" class="form-control" id="remark2" name="remark" disabled="disabled" placeholder="请输入备注">
                                        </div>&ndash;%&gt;
                                        <div class="form-group col-xs-6">
                                            <label>备注</label>
                                            <span id="remark2" class="form-control"></span>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">退出</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>--%>
        <%--查看模态框--%>
        <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="detailModalLabel">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="detailModalLabel">用户详情</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group col-xs-6">
                            <label>用户名</label>
                            <span id="username2" class="form-control"></span>
                        </div>
                        <div class="form-group col-xs-6">
                            <label>昵称</label>
                            <span id="name2" class="form-control"></span>
                        </div>
                        <div class="form-group col-xs-6">
                            <label>邮箱</label>
                            <span id="email2" class="form-control"></span>
                        </div>
                        <div class="form-group col-xs-6">
                            <label>联系方式</label>
                            <span id="tel2" class="form-control"></span>
                        </div>
                        <div class="form-group col-xs-6">
                            <label>备注</label>
                            <span id="remark2" class="form-control"></span>
                        </div>
                    </div>
                    <div class="modal-header">
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>

    </div>


</div>

<script src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/jQueryUI/jquery-ui.min.js"></script>
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/raphael/raphael-min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/morris/morris.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/sparkline/jquery.sparkline.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<script src="${pageContext.request.contextPath}/plugins/knob/jquery.knob.js"></script>
<script src="${pageContext.request.contextPath}/plugins/daterangepicker/moment.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.js"></script>
<script src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="${pageContext.request.contextPath}/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/fastclick/fastclick.js"></script>
<script src="${pageContext.request.contextPath}/plugins/iCheck/icheck.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/adminLTE/js/app.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/treeTable/jquery.treetable.js"></script>
<script src="${pageContext.request.contextPath}/plugins/select2/select2.full.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/bootstrap-markdown.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/locale/bootstrap-markdown.zh.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/markdown.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-markdown/js/to-markdown.js"></script>
<script src="${pageContext.request.contextPath}/plugins/ckeditor/ckeditor.js"></script>
<script src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.js"></script>
<script src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script src="${pageContext.request.contextPath}/plugins/input-mask/jquery.inputmask.extensions.js"></script>
<script src="${pageContext.request.contextPath}/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/chartjs/Chart.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.resize.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.pie.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/flot/jquery.flot.categories.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/ionslider/ion.rangeSlider.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-slider/bootstrap-slider.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap-datetimepicker/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script >
    $(document).ready(function() {
        // 选择框
        $(".select2").select2();

        // WYSIHTML5编辑器
        $(".textarea").wysihtml5({
            locale: 'zh-CN'
        });
    });

    // 设置激活菜单
    function setSidebarActive(tagUri) {
        var liObj = $("#" + tagUri);
        if (liObj.length > 0) {
            liObj.parent().parent().addClass("active");
            liObj.addClass("active");
        }
    }


    $(document).ready(function() {

        // 激活导航位置
        setSidebarActive("admin-datalist");

        // 列表按钮
        $("#dataList td input[type='checkbox']").iCheck({
            checkboxClass: 'icheckbox_square-blue',
            increaseArea: '20%'
        });
        // 全选操作
        $("#selall").click(function() {
            var clicks = $(this).is(':checked');
            if (!clicks) {
                $("#dataList td input[type='checkbox']").iCheck("uncheck");
            } else {
                $("#dataList td input[type='checkbox']").iCheck("check");
            }
            $(this).data("clicks", !clicks);
        });
    });

    /**
     * 保存
     */
    function save() {
        console.log("保存数据");
        var data = $("#add-form").serialize();
        console.log(data);
        var url = "${pageContext.request.contextPath}/user/add_user";
        $.post(url,data,function (response) {
            console.log("收到数据");
            console.log(response);
            alert(response.msg)
            if (response.success){
                window.location.href="${pageContext.request.contextPath}/user/user_list";
            }
        })
    }

    /**
     * 删除
     */
    function  del(id){
        console.log("删除数据");
        console.log(id);
        var url = "${pageContext.request.contextPath}/user/delete_user/"+id;
        $.post(url,id,function (response) {
            console.log("收到数据");
            console.log(response);
            if (response.success){
                window.location.href="${pageContext.request.contextPath}/user/user_list";
            }else {
                alert(response.msg)
            }
        })
    }

    /**
     * 批量删除
     * @param ids
     */
    function delAll() {
        console.log("批量删除");
        var $dataList = $("#dataList input:checked");

       // console.log($dataList);
        var datas = new Array();
        $dataList.each(function (){
            //$(this)
            console.log($(this).val());
            datas.push($(this).val());
        })
        console.log(datas);
        var ids = datas.join(",");
        console.log(ids)
        var data = {ids:ids};
        if(ids==''){
            alert("请选择要删除的数据")
            return;
        }
        var url = "${pageContext.request.contextPath}/user/allDelete_user"
        $.post(url,data,function (response) {
            console.log("收到数据");
            console.log(response);
            alert(response.msg)
            if (response.success){
                window.location.href="${pageContext.request.contextPath}/user/user_list";
            }else {
                alert(response.msg)
            }
        })
    }

    /**
     * 修改
     */
    function update() {
        console.log("修改数据");
        var data = $("#add-form1").serialize();
        console.log(data);
        var url = "${pageContext.request.contextPath}/user/update_user";
        $.post(url,data,function (response) {
            console.log("收到数据");
            console.log(response);
            alert(response.msg)
            if (response.success){
                window.location.href="${pageContext.request.contextPath}/user/user_list";
            }
        })
    }

    /**
     *根据id查询用户
     */
    function getUserById(id){
        console.log("查询用户数据");
        console.log(id);
        var data = {id:id};
        var url = "${pageContext.request.contextPath}/user/get_user";
        $.post(url,data,function (response) {
            console.log("收到数据");
            console.log(response.msg);
           // alert(response.msg)
            if (response.success){
               console.log(response);
                console.log(response.data.id);
                console.log(response.data.username);
                console.log(response.data.name);
                console.log(response.data.email);
                console.log(response.data.tel);
                console.log(response.data.role);
                $("#username1").val(response.data.username);
                $("#name1").val(response.data.name);
                $("#email1").val(response.data.email);
                $("#tel1").val(response.data.tel);
                $("#remark1").val(response.data.remark);
                $("#id1").val(response.data.id);
                $("#username2").text(response.data.username);
                $("#name2").text(response.data.name);
                $("#email2").text(response.data.email);
                $("#tel2").text(response.data.tel);
                $("#remark2").text(response.data.remark);
                $("#id2").text(response.data.id);
            }
            return response;
        })
        return response;
    }

    /**
     * 选择页数
     */
    function selectPages(){
        console.log("选择页数");

        //console.log($("#selectPage").val);
        var myselect=document.getElementById("selectPage");/*拿到select对象*/
        var index=myselect.selectedIndex ;/*拿到选中项的索引,selectedIndex代表的是你所选中项的index*/
        console.log(myselect.options[index].value);/*拿到选中项options的value*/
        var pageSize=myselect.options[index].value;
        window.location.href="${pageContext.request.contextPath}/user/user_list?pageNum=1&pageSize="+pageSize+"&username=${username}";

    }
</script>
</body>

</html>